package com.uit.trip_;

import com.facebook.LoginActivity;
import com.uit.trip_.R;
import com.uit.trip_.tab_activity.Tab_TripHomeActivity;
import com.uit.trip_.tab_activity.Tab_TripLocationActivity;
import com.uit.trip_.tab_activity.Tab_TripSearchActivity;
import com.uit.trip_.tab_activity.Tab_TripWallActivity;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.TabHost;
import android.widget.TabWidget;
import android.widget.TabHost.TabSpec;

public class TripMainActivity extends TabActivity {

	private TabHost tabHost;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.home_activity);
		tabHost = getTabHost();
		// tabHost.getTabWidget().setVisibility(View.GONE);
		initViews();
	}

	public void initViews() {

		Resources res = getResources();
		TabHost.TabSpec tabSpec;
		Intent i;

		tabSpec = tabHost.newTabSpec("Location");
		i = new Intent(this, Tab_TripLocationActivity.class);
		tabSpec.setIndicator("Location",
				res.getDrawable(R.drawable.tab_location));
		tabSpec.setContent(i);
		tabHost.addTab(tabSpec);

		tabSpec = tabHost.newTabSpec("Home");
		i = new Intent(this, Tab_TripHomeActivity.class);
		tabSpec.setIndicator("Home", res.getDrawable(R.drawable.tab_home));
		tabSpec.setContent(i);
		tabHost.addTab(tabSpec);

		tabSpec = tabHost.newTabSpec("Wall");
		i = new Intent(this, Tab_TripWallActivity.class);
		tabSpec.setIndicator("Wall", res.getDrawable(R.drawable.tab_wall));
		tabSpec.setContent(i);
		tabHost.addTab(tabSpec);

		tabSpec = tabHost.newTabSpec("Search");
		i = new Intent(this, Tab_TripSearchActivity.class);
		tabSpec.setIndicator("Search", res.getDrawable(R.drawable.tab_search));
		tabSpec.setContent(i);
		tabHost.addTab(tabSpec);

		tabHost.setCurrentTab(1);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add(0, 0, 0, "Logout");
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case 0:
			setResult(RESULT_OK);
			finish();
			break;

		default:
			break;
		}
		return super.onOptionsItemSelected(item);
	}

}
